package com.yangzb.neo4j.service.impl;

import com.google.common.collect.Lists;
import com.yangzb.neo4j.node.StudentNode;
import com.yangzb.neo4j.repository.StudentRepository;
import com.yangzb.neo4j.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    StudentRepository studentRepository;
    @Override
    public List<StudentNode> getAll() {
        Iterable<StudentNode> allProgramLanguage = studentRepository.findAll();
        List<StudentNode> programLanguageList = Lists.newArrayList(allProgramLanguage);
        return programLanguageList;
    }

    @Override
    public int saveStudentNode(StudentNode studentNode) {
//        if(StringUtils.isEmpty(programLanguage.getUuid())){
//            studentNode.setId(UUID.randomUUID().toString());
//        }

        StudentNode save = studentRepository.save(studentNode);
        if (save != null){
            return 200;
        }else {
            return 404;
        }
    }
}
